import 'package:word_game/battle/monster_manager.dart';

import 'monster.dart';

class MonsterCluster extends Monster {
  List<Monster> members = [];
  MonsterCluster(Map map) : super(map) {
    if (map != null) {
      for (var item in map['monsters']) {
        Monster obj = Monster({});
        if (item is String) {
          obj = MonsterManager.instance.objectWithCode(item);
        } else if (item is Map) {
          obj = Monster(item);
        }
        members.add(obj);
      }
    }
  }

  @override
  void copyData(dynamic obj) {
    super.copyData(obj);
    for (var member in obj.members) {
      var newObj = Monster(null);
      newObj.copyData(member);
      this.members.add(newObj);
    }
  }
  
  void addMonsters(List<Monster> monsters) {
    members.addAll(monsters);
  }
}